<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>vue1</title>
        <script src="js/vue.js"></script>
        <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            #app{
                width: 800px;
                height: 600px;
                margin: 200px auto;
                background: rgba(207, 210, 209, 1);
            }
            .header h1{
                width: 100%;
                height: 60px;
                line-height: 60px;
                text-align: center;
                color: rgb(62, 64, 66);
                background: rgb(179, 179, 192);
            }
            .header input{
                width: 100%;
                height: 60px;
                line-height: 60px;
                background:  rgb(141, 141, 125);
                border: 0 solid transparent;
            }
            .main ul{
                list-style: none;
            }
            .main li{
                height: 20px;
                background: rgb(182, 168, 166);
                margin: 0 20px;
                margin-top: 20px;
                padding: 10px;
                border-radius: 8px;

            }
            .main li button{
                display: none;
                float: right;
            }
            .main li:hover button{
                display: block;
            }
        </style>
    </head>
    <body>
        <div id="app">
            <header class="header">
                <h1>记事本</h1>
                <input type="text" autofocus="autofocus" autocomplete="off" placeholder="请输入任务" class="new-todo" 
                v-model="value" @keyup.enter="add">
            </header>
            <section class="main">
                <ul class="todo-list">
                    <li class="todo" v-for="(item,index) in list">
                        <div class="view">
                            <span class="index">{{ index+1 }}</span>
                            <label>{{item}}</label>
                            <button class="destroy" @click="remove(index)">X</button>
                        </div>
                    </li>
                </ul>
            </section>
            <footer class="footer">

            </footer>

        </div>
        <script>
            let vue = new Vue({
        // 告诉vue的实例对象，将来需要控制界面上的那个区域
                el:'#app',
                data:{
                    name:"内容1",
                    list:["11111111","22222","333333"],
                    value:""
                },
                methods: {
                    add(){
                        if(this.value.length == 0) return ''
                        this.list.push(this.value)
                        this.value = ""
                    },
                    remove(index){
                        this.list.splice(index, 1);
                    }
                },
            });
        </script>
    </body>
</html>